
const selectData = [
  {
    value: '选项1',
    label: '黄金糕',
  },
  {
    value: '选项2',
    label: '双皮奶',
  },
  {
    value: '选项3',
    label: '蚵仔煎',
  },
  {
    value: '选项4',
    label: '龙须面',
  },
  {
    value: '选项5',
    label: '北京烤鸭',
  },
]

export default {
  select: (opt, data) => {
    let option = []
    option = selectData
    return (
      <el-select v-model={data[opt.prop]} placeholder="请选择" size="small">
        {option.map((item) => {
          return (
            <el-option
              key={item.value}
              label={item.label}
              value={item.value}>
            </el-option>
          )
        })}
      </el-select>
    )
  },
  selectMultiple: (opt, data) => {
    return (
      <el-select v-model={data[opt.prop]} multiple placeholder="请选择" size="small">
        {selectData.map((item) => {
          return (
            <el-option
              key={item.value}
              label={item.label}
              value={item.value}>
            </el-option>
          )
        })}
      </el-select>
    )
  },
  date: (opt, data) => {
    return (
      <el-date-picker
        type="date"
        v-model={data[opt.prop]}
        placeholder="选择日期"
        size="small">
      </el-date-picker>
    )
  },
  daterange: (opt, data) => {
    return (
      <el-date-picker
        v-model={data[opt.prop]}
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        size="small">
      </el-date-picker>
    )
  },
  radio: (opt, data) => {
    return (
      <>
        <el-radio v-model={data[opt.prop]} label="1">是</el-radio>
        <el-radio v-model={data[opt.prop]} label="0">否</el-radio>
      </>
    )
  },
  input: (opt, data) => {
    return (
      <el-input v-model={data[opt.prop]} placeholder="请输入" size="small"></el-input>
    )
  },
  annex: (scope, item) => {
    const url = 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'
    const srcList = [
      'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
      'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg',
    ]
    return (
      <el-image
        style="width: 60px; height: 40px"
        src={url}
        preview-src-list={srcList}>
      </el-image>
    )
  },
}
export const excludeItems = ['text', 'selection', 'index']

export const typeDict = {
  select: '',
  selectMultiple: [],
  date: '',
  daterange: '',
  input: '',
}
export function randomString (e) {
  e = e || 32
  var t = 'abcdefhijkmnprstwxyz'
  var a = t.length
  var n = ''
  for (let i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a))
  return n
}
